package com.example.xutils1.adapter;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.xutils1.R;
import com.example.xutils1.bean.JiuJiuItem;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.bitmap.BitmapDisplayConfig;

public class JiuJiuListAdapter extends SuperBaseAdapter<JiuJiuItem> {
 
	private BitmapUtils mBitmapUtils;
	private BitmapDisplayConfig mConfig;

	public JiuJiuListAdapter(Context ctx) {
		super(ctx);

		mBitmapUtils = new BitmapUtils(ctx);
		mConfig = new BitmapDisplayConfig();

		Drawable drawable = ctx.getResources().getDrawable(R.drawable.stub);
		mConfig.setLoadingDrawable(drawable);
		mConfig.setLoadFailedDrawable(drawable);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		View view = convertView;

		if (view == null) {
			view = mInflater.inflate(R.layout.item_jiujiu, null);
		}

		JiuJiuItem item = getItem(position);

		ImageView img = (ImageView) view.findViewById(R.id.img);
		TextView title = (TextView) view.findViewById(R.id.title);
		TextView price = (TextView) view.findViewById(R.id.price);
		TextView originprice = (TextView) view.findViewById(R.id.originalprice);
		TextView discount = (TextView) view.findViewById(R.id.discount);

		mBitmapUtils.display(img, item.pic_url, mConfig);

		title.setText(item.title);
		price.setText("锟�" + item.now_price);
		originprice.setText("鍘熶环:" + item.origin_price);
		discount.setText(item.discount + "鎶�);

		return view;
	}
}